package com.tpshion.cloud.auth.domain.dto;

import org.springframework.util.StringUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

@Valid
public class UpdateRoleDto {

    @Size(max = 64, message = "角色id长度不能超过64")
    @NotEmpty(message = "角色id不能为空")
    private String roleId;

    @NotEmpty(message = "角色名称不能为空")
    @Size(max = 15, message = "角色名称长度不能超过15位")
    private String roleName;

    @Size(max = 80, message = "角色说明不能超过80位")
    private String note;

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public String toString() {
        return "UpdateRoleDto{" +
                "roleId='" + roleId + '\'' +
                ", roleName='" + roleName + '\'' +
                ", note='" + note + '\'' +
                '}';
    }

    public void init(){
        this.roleId = this.roleId.trim();
        this.roleName = this.roleName.trim();
        this.note = StringUtils.isEmpty(this.note) ? this.note : this.note.trim();
    }
}
